$(function($){
    (function(){
        pos = 0;
        ticking = false;
        var header = document.querySelector(".header");
        window.addEventListener("scroll", function(e){
            pos = window.scrollY;
            if(pos > 5 && !ticking){
                $('header').addClass("head");
                $('header>p').addClass('p');
                ticking = true;
            }
            if(pos < 5 && ticking){
                $('header').removeClass('head');
                $('header>p').removeClass('p');
                ticking = false;
            }
        });
    })();
    var swiper = new Swiper('.swiper-container', {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        autoplay:2000
    });
    var liH = $('#ul').children().eq(0).height()
    var ulH = $('#ul').height()
    var ulT =  $('#ul').position().top
    var count = 0;
       var id = setInterval(function () {
                count -= liH;
                $("#ul").animate({ top: count + "px" }, 500,function(){
                    if(ul.style.top == -(ulH - liH) + 'px'){
                        count = 0;
                $("#ul").css("top", "0px");
                    }
                })
        },2000)
        
        
    
        var timeout;
        timeout = setTimeout(function(){
            　　　$.ajax({
                url:"json/index.json",
                type:"get",
                beforeSend:function(){
                    
                    $('.show').show()
                },
                complete:function(){
                    $('.show').hide();
                },
                success:function(res){
                    var str = template('temp-test',{arr:res});
                    $('.box').html(str);
                },
                
            })　
        }, 3000);
        $('.search').click(function(){
            location.href = 'html/search.html';
        })
});
